package com.lg.my.netty.codec;

import com.lg.netty.codec.ProtostuffUtil;
import com.lg.netty.codec.User;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

import java.nio.CharBuffer;

/**
 * @author by Mr. Li 2021/4/22 6:36
 */
public class ObjectEncodeByProtocl extends MessageToByteEncoder<User> {
    @Override
    protected void encode(ChannelHandlerContext ctx, User msg, ByteBuf out) throws Exception {

        out.writeBytes(ProtostuffUtil.serializer(msg));
    }
}
